Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(features): rename runtimeFlags to lwcRuntimeFlags #3004

Merged
merged 4 commits into from
Aug 19, 2022

Conversation

nolanlawson
Copy link
Collaborator

Details

In our build artifacts for engine-dom and engine-server, I would like to be able to replace runtime flags with true and false for tree-shaking purposes. (I.e. a consumer can tree-shake out any runtime features they are not using.)

This is possible today with e.g. @rollup/plugin-replace, but currently our build artifacts contain things like:

if (runtimeFlags.ENABLE_REACTIVE_SETTER) {

... which would require:

replace({
  'runtimeFlags.ENABLE_REACTIVE_SETTER': 'false',
  preventAssignment: true
})

I propose renaming runtimeFlags to the more explicit lwcRuntimeFlags, because:

  1. It makes it more obvious that you're replacing an LWC runtime flag.
  2. It matches the name of the global anyway.
  3. It completely eliminates the possibility of collision with some other library/framework using a variable called runtimeFlags.

So we would have:

if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {

and:

replace({
  'lwcRuntimeFlags.ENABLE_REACTIVE_SETTER': 'false',
  preventAssignment: true
})

Does this pull request introduce a breaking change?

  • ✅ No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • ✅ No, it does not introduce an observable change.

GUS work item

@@ -79,4 +79,6 @@ export function setFeatureFlagForTest(name: FeatureFlagName, value: FeatureFlagV
}
}

export const runtimeFlags = lwcRuntimeFlags; // backwards compatibility for before this was renamed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good. Just curious what usecase will require this backwards compatibility. Does anybody use runtimeFlags from @lwc/features outside of our repos?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of any, but since this is a public package on npm that (in theory) anyone could use, and since the fix was a one-liner, I added it in. We could definitely remove it in a breaking release. I'll add that to the wishlist: #2964

@nolanlawson nolanlawson merged commit 13ffc9c into master Aug 19, 2022
@nolanlawson nolanlawson deleted the nolan/rename-runtime-flags branch August 19, 2022 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants